<!DOCTYPE html>
<html>
<head>
    <title>Molecular Beam Apparatus</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <canvas id="physicsCanvas" width="750" height="550"></canvas>
    <script>
        const canvas = document.getElementById('physicsCanvas');
        const ctx = canvas.getContext('2d');

        // Style settings
        ctx.lineWidth = 2;
        ctx.strokeStyle = 'black';
        ctx.fillStyle = 'black';
        ctx.font = "20px sans-serif";
        
        // --- Drawing Shapes ---

        // Oven
        ctx.beginPath();
        ctx.moveTo(200, 150);
        ctx.lineTo(50, 150);
        ctx.lineTo(50, 300);
        ctx.lineTo(200, 300);
        ctx.stroke();

        // Vacuum Chamber
        ctx.beginPath();
        ctx.moveTo(200, 150);
        ctx.lineTo(200, 100);
        ctx.lineTo(650, 100);
        ctx.lineTo(650, 350);
        ctx.lineTo(550, 350);
        ctx.lineTo(550, 400);
        ctx.lineTo(500, 400);
        ctx.lineTo(500, 350);
        ctx.lineTo(200, 350);
        ctx.lineTo(200, 300);
        ctx.stroke();

        // Collimating Slits
        const slit_x1 = 320;
        const slit_x2 = 420;
        const slit_gap_y1 = 215;
        const slit_gap_y2 = 240;
        const slit_top = 150;
        const slit_bottom = 320;
        
        ctx.beginPath();
        ctx.moveTo(slit_x1, slit_top);
        ctx.lineTo(slit_x1, slit_gap_y1);
        ctx.moveTo(slit_x1, slit_gap_y2);
        ctx.lineTo(slit_x1, slit_bottom);
        ctx.stroke();

        ctx.beginPath();
        ctx.moveTo(slit_x2, slit_top);
        ctx.lineTo(slit_x2, slit_gap_y1);
        ctx.moveTo(slit_x2, slit_gap_y2);
        ctx.lineTo(slit_x2, slit_bottom);
        ctx.stroke();
        
        // Molecular Beam (dashed lines)
        ctx.beginPath();
        ctx.setLineDash([7, 5]);
        // Upper line
        ctx.moveTo(200, 220);
        ctx.lineTo(620, 205);
        // Lower line
        ctx.moveTo(200, 235);
        ctx.lineTo(620, 255);
        ctx.stroke();
        ctx.setLineDash([]); // Reset to solid line

        // Pump outlet
        ctx.beginPath();
        ctx.moveTo(525, 400);
        ctx.lineTo(525, 430);
        // Arrowhead
        ctx.moveTo(525, 430);
        ctx.lineTo(520, 422);
        ctx.moveTo(525, 430);
        ctx.lineTo(530, 422);
        ctx.stroke();

        // --- Drawing Text ---
        ctx.textAlign = 'center';
        
        ctx.fillText("oven", 125, 230);
        ctx.fillText("collimating slits", (slit_x1 + slit_x2) / 2, 140);
        ctx.fillText("vacuum", 480, 300);
        
        ctx.textAlign = 'center';
        ctx.fillText("to pump", 525, 455);
        
        ctx.fillText("Fig. 2.40.", 375, 520);

    </script>
</body>
</html>